import { Controller, Get, Param } from '@nestjs/common'
import { BlogService } from './blog.service'
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'
import { BlogPost } from './schemas/blog-post.schema'

@Controller('api/blog')
@ApiTags('Blog')
export class BlogController {
  constructor(private readonly blogService: BlogService) {}

  @Get('posts')
  @ApiOperation({ summary: 'Get all blog posts' })
  @ApiResponse({ status: 200, description: 'List of blog posts', type: [BlogPost] })
  async getPosts() {
    return this.blogService.findAll()
  }

  @Get('posts/:id')
  @ApiOperation({ summary: 'Get a single blog post' })
  @ApiResponse({ status: 200, description: 'Blog post details', type: BlogPost })
  async getPost(@Param('id') id: string) {
    return this.blogService.findOne(id)
  }
}